package com.piggy.common.core.enums;

import cn.hutool.core.util.ObjectUtil;
import lombok.AllArgsConstructor;
import lombok.Getter;

@AllArgsConstructor
@Getter
public enum RedisKeyEnums {
    SysDept("sys_dept", "部门", RedisKeyEnums.sysPrefix,RedisKeyEnums.DayOut),
    SysClient("sys_oauth_client_details", "终端配置表", RedisKeyEnums.sysPrefix,-1L),
    SysUser("sys_user", "用户表", RedisKeyEnums.sysPrefix,RedisKeyEnums.DayOut),
    SysUserName("sys_user_name", "用户表", RedisKeyEnums.sysPrefix,RedisKeyEnums.DayOut),
    TdmsCoreBusiness("tdms_core_business", "企业信息", RedisKeyEnums.msPrefix,RedisKeyEnums.DayOut),
    TdmsCoreBusinessOrg("tdms_core_business_org", "企业信息", RedisKeyEnums.msPrefix,RedisKeyEnums.DayOut),
    TdmsCoreBusinessDept("tdms_core_business_dept", "企业信息", RedisKeyEnums.msPrefix,RedisKeyEnums.DayOut),
    TdmsBankAccount("tdms_bank_account","银行账户信息",RedisKeyEnums.msPrefix,RedisKeyEnums.DayOut),

    FcmsSceneType("fcms_scene_type", "场景类型表", RedisKeyEnums.msPrefix,RedisKeyEnums.DayOut),
    FcmsScene("fcms_scene", "场景表", RedisKeyEnums.msPrefix,RedisKeyEnums.DayOut),
    FcmsSceneKey("fcms_scene_key", "场景表", RedisKeyEnums.msPrefix,RedisKeyEnums.DayOut),
    TdmsBusineseSceneRl("tdms_businese_scene_rl", "企业场景关联表", RedisKeyEnums.msPrefix,RedisKeyEnums.DayOut),
    TdmsBusineseSceneRlScene("tdms_businese_scene_rl_scene", "企业场景关联表", RedisKeyEnums.msPrefix,RedisKeyEnums.DayOut),
    TdmsBusineseSceneRlSceneAndOrg("tdms_businese_scene_rl_scene_org", "企业场景关联表", RedisKeyEnums.msPrefix,RedisKeyEnums.DayOut),
    TdmsBusineseSceneRlSceneKeyAndOrg("tdms_businese_scene_rl_scenekey_org", "企业场景关联表", RedisKeyEnums.msPrefix,RedisKeyEnums.DayOut),

    TOrderSeq("t_order_seq", "订单序号表", RedisKeyEnums.seqPrefix,RedisKeyEnums.DayOut),

    TOrderInvoiceOcrLock("order_invoice_ocr_lock", "订单发票ocr识别", RedisKeyEnums.orderPrefix,RedisKeyEnums.DayOut),
    TOrderInvoiceOcrId("order_invoice_ocr_id", "订单发票ocr识别id号", RedisKeyEnums.orderPrefix,RedisKeyEnums.DayOut),

    ErpSyncDepotHeadLock("erpSyncDepotHeadLock", "erp同步订单中心锁", RedisKeyEnums.erpPrefix,RedisKeyEnums.DayOut),
    ErpSyncDepotHeadId("erpSyncDepotHeadId", "erp同步订单中心id号", RedisKeyEnums.erpPrefix,RedisKeyEnums.DayOut),

    RxtAccOrderLock("rxtAccOrderLock", "融信通清分订单锁", RedisKeyEnums.rxtPrefix, RedisKeyEnums.DayOut),
    RxtOrderOverDayLock("rxt_order_overday_lock", "融信通融资、转让订单锁", RedisKeyEnums.rxtPrefix,RedisKeyEnums.DayOut),
    RxtOrderOverDayNotifyLock("rxt_order_overday_notify_lock", "融信通订单超时通知", RedisKeyEnums.rxtPrefix,360L),
    RxtAccOrderOverDayNotifyLock("rxt_acc_order_overday_notify_lock", "待清分融信通订单超时通知", RedisKeyEnums.rxtPrefix,360L),

    ;

    /** key **/
    private final String code;
    /** 描述 **/
    private final String desc;
    /**
     * 前缀
     */
    private final String prefix;
    private final Long day;

    private final static String sysPrefix = "system";
    private final static String msPrefix = "ms";
    private final static String seqPrefix = "seq";
    private final static String orderPrefix = "order";
    private final static String erpPrefix = "erp";
    private final static String rxtPrefix = "rxt";
    private final static long DayOut = 30L;


    public String getKey(Object...keys) {
        StringBuilder redisKey = new StringBuilder(this.prefix);
        redisKey.append(":").append(this.code);
        for(Object key : keys) {
            if (ObjectUtil.isNotNull(key)) {
                redisKey.append(":").append(key);
            }
        }
        return redisKey.toString();
    }

}
